package com.yunhe.task.client;

import com.yunhe.common.model.data.PointNumberDTO;
import com.yunhe.task.client.fallback.MeasHistoryFallbackFactory;
import com.yunhe.common.model.DomainList;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.data.MeasurePointMap;
import com.yunhe.common.model.data.Measurement;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 量测历史数据Feign客户端
 * @author liuronglei
 */
@FeignClient(value = "yh-meas-history", fallbackFactory = MeasHistoryFallbackFactory.class)
@RequestMapping("/measurements")
public interface MeasHistoryClient {

    @RequestMapping(value = "/batch", method = RequestMethod.POST)
    ResponseEntity<ResultObject<MeasurePointMap>> createMeasurementAsync(@RequestBody DomainList<Measurement> domainList);

    /**
     * 根据条件获得量测列表（post方式）
     * @param dtime 时间范围
     * @param pointNumberDTO
     */
    @RequestMapping(value = "/batchGet", method = RequestMethod.POST)
    ResponseEntity<ResultObject<List<List<Measurement>>>> searchByPost(@RequestParam("dtime") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") List<Date> dtime,
                                                                 @RequestBody PointNumberDTO pointNumberDTO);
}
